<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <title>设备信息</title>
  <t:base type="jquery,easyui,tools,DatePicker"></t:base>
  <script type="text/javascript">
  //编写自定义JS代码
  </script>
 </head>
 <body>
  <t:formvalid formid="formobj" dialog="true" layout="table" 
  			  action="deviceAppointApplyController.do?doAdd" tiptype="3" 
  			  callback="afterSuccessSubmit" >
		<input id="deviceId" name="deviceId" type="hidden" value="${device.id}"> 
		<table style=" " cellpadding="0" cellspacing="1" class="formtable">
				<tr>
					<td align="right">
						<label class="Validform_label">
							设备信息:
						</label>
					</td>
					<td class="value"> 
                	     品牌：${device.brand.brandName}型号：${device.model.modelName}编号:${device.deviceNo}
					</td> 
				</tr>
				<tr>
					<td align="right">
						<label class="Validform_label">
							申请领用时间:
						</label>
					</td>
					<td class="value"> 
                	    <input name="applyStartString" id="applyStartString" datatype='*'>
							
						<span class="Validform_checktip"></span>
						<label class="Validform_label" style="display: none;">领用时间</label> 
					</td>
					 
				</tr>	
				<tr>
					<td align="right">
						<label class="Validform_label">
							申请归还时间:
						</label>
					</td>
					<td class="value"> 
                	    <input name="applyEndString" id="applyEndString" datatype='*'>
							
						<span class="Validform_checktip"></span>
						<label class="Validform_label" style="display: none;">归还时间</label> 
					</td>
					 
				</tr>	
				 
				<tr>
					<td align="right">
						<label class="Validform_label">
							备注:
						</label>
					</td>
					<td class="value" colspan="4">
						  	 <textarea style="width:300px;height:100px;" class="inputxt" rows="6" id="remark" name="remark" maxlength="200"></textarea>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">备注</label>
						</td>
			 
				</tr>
			</table>
		</t:formvalid>
 </body>
 <script>
  
 	
 	$(document).ready(function(){
 		//给时间控件加上样式
 		$("input[name='applyStartString']").attr("class","Wdate").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});});
 		$("input[name='applyEndString']").attr("class","Wdate").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});});
   });
 	
 	function validateInfo(openTimeBegin,openTimeEnd){
 		var applyDateValue = $('#applyStartString').val();
 		if(applyDateValue == "") {
 			tip('请选择领用时间');
 			return false;
 		}
		var applyDate = new Date(applyDateValue.replace(/-/g,"/"));
		
		var applyEndDate =  $('#applyEndString').val();
		if(applyEndDate == "") {
			tip('请选择归还时间');
			return false;
		}
		applyEndDate = new Date(applyEndDate.replace(/-/g,"/"));
		
		var now = new Date();
		var days = (applyDate - now )/1000/60/60/20;
		if(days < 1){
			tip("请至少提前一天预约！");
			return false;
		} 
	   
			
		if(applyDate -openTimeEnd > 0){
			tip('预约时间不能晚于开放时间！')
			return false;
		}
			
		if(applyDate - openTimeBegin < 0){
			tip('预约时间不能早于开放时间！')
			return false; 					
		}
		
		
		
		if(applyDate - applyEndDate > 0){
			tip("开始时间不能大于结束时间！");
			return false;
		}
		
		window.top.optOK = true;
		return true;
 	}
 	
 	
 	
 </script>
 